<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>7_1_3-2-响应式对象解构赋值</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

  <div id="Application"></div>
  <script>
    const App = Vue.createApp({
      setup() {
        let myObject = Vue.reactive({
          value: 0,
        });
        //对myObject对象进行解构赋值，将value属性单独提取出来
        //解构赋值时，value会直接被转成ref变量
        let { value } = Vue.toRefs(myObject);
        function click() {
          value.value += 1;
          console.log(value.value);
        }
        return {
          value,
          click,
        };
      },
      template: `
            <h1>测试数据：{{value}}</h1>
                <button @click="click">点击</button>
            `,
    });
    App.mount("#Application");
  </script>
</body>

</html>